/**
 * 
 */
package com.gson.inter;

import java.io.IOException;
import java.util.Iterator;
import java.util.ArrayList;
import org.jdom.JDOMException;

/**
 * @作者 Stone
 * @创建日期 2013-10-18 下午03:12:06
 * @版本 V1.0
 * @类说明
 */
public class Demo {
	public static void main(String[] args) {

		String rss_url = "http://news.google.com/news?pz=1&cf=all&ned=cn&hl=zh-CN&output=rss";

		try {
			RssViewer new_viewer = new RssViewer(rss_url);
			String root_title = new_viewer.getRoot_Title();
			System.out.println("標題是:" + root_title);
			ArrayList item_list = new_viewer.getRSS_items();
			Iterator itx = item_list.iterator();

			while (itx.hasNext()) {

				RssChild rsschild = (RssChild) itx.next();
				System.out.println("====|"+rsschild.getTitle().replaceAll("\n", "").replaceAll("\t", "")+"|====");
				String link = rsschild.getLink();
				link = link.substring(link.indexOf("&url=")+5);
				System.out.println(link);
				System.out.println();
				System.out.println();
			}

		} catch (JDOMException jdem) {

			System.out.println("解析xml文件發生錯誤:" + jdem.getMessage());

		} catch (IOException ioe) {

			System.out.println("打開url發生錯誤" + ioe.getMessage());
		}
	}
}
